#set($title = '首页')
<style type="text/css">
td{
 width:100px;
 text-align:center
}

        .pagination ul > li > input{
            vertical-align: top;
            -webkit-border-radius: 0;
             -moz-border-radius: 0;
                  border-radius: 0;
            height:auto;
            *height: 20px;
            margin-bottom:0px;
            background-color: #fff;
            border-left-width: 0;
            width:40px;
            float:left;
            min-height: auto;
            *min-height: 20px;
        }
        </style>
<table>
	<tr>
		<td>作者</td>
		<td>书名</td>
		<td>价格</td>
		<td>出版时间</td>
		<td>类型</td>
	</tr>
#foreach($data in $!{pager.list})
	<tr class="item" style="cursor:pointer">
		<td>$!{data.AUTHOR}</td>
		<td>$!{data.NAME}</td>
		<td>#formatMoney($!{data.PRICE})</td>
		<td>$!{data.PUBLISHDATE}</td>
		<td>$!{data.TYPE_NAME}</td>
	</tr>
#end
	<tr>
		<td>总页数:$!{pager.pages}</td>
		<td>第$!{pager.pageNum}页</td>
		<td>总条数：$!{pager.total}</td>
		<td onclick="window.location.href='queryAll?cur_page=1'">首页</td>
		#if($!{pager.hasPreviousPage})
		<td onclick="window.location.href='queryAll?cur_page=$!{pager.prePage}'">上一页</td>
		#end
		#foreach($bean in $!{pager.navigatepageNums})
		  #if($!{pager.pageNum} == $!{bean})
		  <td onclick="window.location.href='queryAll?cur_page=$!{bean}'" style="color:red">$!{bean}</td>
		  #else
		  <td onclick="window.location.href='queryAll?cur_page=$!{bean}'">$!{bean}</td>
		  #end
		
		#end
		#if($!{pager.hasNextPage})
		<td onclick="window.location.href='queryAll?cur_page=$!{pager.nextPage}'">下一页</td>
		#end
		<td onclick="window.location.href='queryAll?cur_page=$!{pager.lastPage}'">末页</td>
	</tr>
</table>
<div class="pagination pagination-right">
            <ul>
                <li><a href="queryAll?cur_page=$!{pager.firstPage}"><i class="icon-fast-backward"></i></a></li>
                <li class="previous"><a href="queryAll?cur_page=$!{pager.prePage}">Previous</a></li>
                #foreach($bean in $!{pager.navigatepageNums}) 
                	#if($!{pager.pageNum} == $!{bean})
                	<li class="active"><a href="queryAll?cur_page=$!{bean}">$!{bean}</a></li>
                	#else
                	<li class="disabled"><a href="queryAll?cur_page=$!{bean}">$!{bean}</a></li>
                	#end
                #end
                <li><a href="queryAll?cur_page=$!{pager.nextPage}">Next</a></li>
                <li><a href="queryAll?cur_page=$!{pager.lastPage}"><i class="icon-fast-forward"></i></a></li>
                <li><input type="text" class="input"></li>
                <li><a href="javascript:void();" onclick="window.location.href='queryAll?cur_page='+$('.input').val()">Go</a></li>
            </ul>
        </div>
<div class="pagination">
<ul >
    <li><a href="queryAll?cur_page=$!{pager.prePage}">&laquo;</a></li>
    #foreach($bean in $!{pager.navigatepageNums})
                	#if($!{pager.pageNum} == $!{bean})
                	<li class="active"><a href="queryAll?cur_page=$!{bean}">$!{bean}</a></li>
                	#else
                	<li class="disabled"><a href="queryAll?cur_page=$!{bean}">$!{bean}</a></li>
                	#end
                #end
    <li><a href="queryAll?cur_page=$!{pager.nextPage}">&raquo;</a></li>
</ul>
</div>
<div id="tt" style="width:auto;height:300px;background-color: #cacaca">
	<table id="usertb" style="width:auto;height:300px" toolbar="#toolbar">
	<thead>
		<tr>
			<th field="name">作者</th>
			<th field="age">书名</th>
			<th field="country">价格</th>
			<th field="sex">类型</th>
			<th field="count">数量</th>
		</tr>
		</thead>
	</table>
	<p>总价：￥<span id="pp">0.00</span></p>
</div>
<div id="toolbar">
	<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newUser()">New User</a>
	<a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editUser()">Edit User</a>
	<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroyUser()">Remove User</a>
</div>
#set($ttt = $request.getParameter('cur_page')))
#foreach($data in $goodsfun.queryCountrys().get('con')) 
	<script>alert("$data.COUNTRY_NAME"+"$!{ttt}"+"=================");</script>
#end
<script>
var data = {
		"total" : 0,
		"rows" : []
	};
	var tprice = 0;
	$(function(){
		$('#usertb').datagrid({
			singleSelect:true
		});
		$('.item').draggable({
			revert:true,
			proxy:'clone',
			
		});
		$('#tt').droppable({
			onDrop:function(e,source){
				var name = $(source).find('td:eq(0)').html();
				var age = $(source).find('td:eq(1)').html();
				var country = $(source).find('td:eq(2)').html();
				var sex = $(source).find('td:eq(4)').html();
				addP(name,age,parseFloat(country),sex);
			}
		});
	});
	function p(pr){
		return pr.toFixed(2);
	}
	function addP(name,age,country,sex){
		function add(){
		for(var i = 0; i < data.total;i++ ){
			var row = data.rows[i];
			if(row.age == age){
				row.count += 1;
				row.country+=country;
				return;
			}
			
			}
		data.total += 1;
		
		data.rows.push({name:name,age:age,country:country,sex:sex,count:1});
		}
		add();
		tprice +=country;
	$('#usertb').datagrid('loadData',data);
	$('#pp').html(p(tprice));
	}
</script>
